<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * sfWidgetFormInput represents an HTML input tag.
 *
 * @package    symfony
 * @subpackage widget
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
 * @version    SVN: $Id: sfWidgetFormInput.class.php 9046 2008-05-19 08:13:51Z FabianLange $
 */
class inputImage1Tag extends sfWidgetFormInput
{
  /**
   * @param array $options     An array of options
   * @param array $attributes  An array of default HTML attributes
   *
   * @see sfWidgetFormInput
   */
  protected function configure($options = array(), $attributes = array())
  {
    parent::configure($options, $attributes);

    
    
    $this->setOption('type', 'file');
    $this->setOption('needs_multipart', true);
  }
  
public function render($name, $value = 'not', $attributes = array(), $errors = array())
  {
  	sfLoader::loadHelpers ( 'Highslide' );
  	$img = highslide('/uploads/material/'.$attributes['folder'].'/'.$value, '/uploads/material/'.$attributes['folder'].'/_thumbnail/'.$value, $options = array());
  	$str='';	
  	$path = sfConfig::get('sf_upload_dir').'/material/'.$attributes['folder'].'/_thumbnail/'.$value;
    if(file_exists($path) and $value!='')
    {
  	$l = link_to('Удалить',sfContext::getInstance()->getRequest()->getParameter('module').'/edit?folder='.$attributes['folder'].'&del_img1=true&id='.$attributes['mat_id']);
  	$str = '<div style="float:right; margin-top: -10px">'.$img.'<br />'.$l.'</div>';
    }
    return $this->renderTag('input', array_merge(array('type' => $this->getOption('type'), 'name' => $name, 'value' => $value), $attributes)).$str;
  }
}